<template>
    <div class="qq">
        <van-dialog
                v-model="dialog_show"
                title="关注我们"
                :before-close="beforeClose"
                >
            <p>关注公众号<span class="word gongzhonghao">蒸汽小兔</span>或者加新QQ群<span class="word qqqun">967700061</span>（以前的QQ群，暂时用不了）。都可以有机会获得更多大作，可爱女装群主不定时QQ群和微信发免费key!（点击复制）</p>
        </van-dialog>
    </div>
</template>

<script>

import bus from '@/utils/bus'

export default {
  data() {
    return {
      dialog_show: true
    };
  },
  methods: {
    beforeClose(action, done) {
      if (action === "confirm") {
        done();
      } else {
        done();
      }
    }
  },
  mounted() {
    bus.$on("close_zhishi", () => {
      const _this = this;
      setTimeout(() => {
        _this.dialog_show = true;
      }, 500);
    });
    const btn1 = document.querySelector(".gongzhonghao");
    const btn2 = document.querySelector(".qqqun");
    const _this = this;
    btn1.addEventListener("click", () => {
      const input = document.createElement("input");
      document.body.appendChild(input);
      input.setAttribute("value", "蒸汽小兔");
      input.select();
      if (document.execCommand("copy")) {
        document.execCommand("copy");
        _this.$toast({
          message: "复制成功",
          position: "bottom"
        });
      }
      document.body.removeChild(input);
    });
    btn2.addEventListener("click", () => {
      const input = document.createElement("input");
      document.body.appendChild(input);
      input.setAttribute("value", "967700061");
      input.select();
      if (document.execCommand("copy")) {
        document.execCommand("copy");
        _this.$toast({
          message: "复制成功",
          position: "bottom"
        });
      }
      document.body.removeChild(input);
    });
  }
};
</script>

<style lang="scss">
.qq {
  text-align: left;

  .word {
    color: #ef6a6e;
    padding-left: 1em;
    padding-right: 1em;
    font-size: 18px;
  }

  .van-dialog__header {
    font-size: 20px;
    font-weight: 500;
  }

  .van-dialog__content {
    padding: 15px;
  }
}
</style>
